package org.grow.auth.service;

import org.grow.auth.dao.UltraInfoMapper;
import org.grow.auth.domain.UltraInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: xwg
 * @CreateDate: 2023/9/22
 */

@Service
public class UltraInfoService {

    @Autowired
    private UltraInfoMapper ultraInfoMapper;

    public UltraInfo findByOfficialName(String currentUser) {
        UltraInfo ultraInfo = ultraInfoMapper.findByOfficialName(currentUser);
        if (ultraInfo == null) {
            UltraInfo defaultInfo = new UltraInfo();
            defaultInfo.setOfficialName(currentUser);
            ultraInfoMapper.insert(defaultInfo);
            return defaultInfo;
        }
        return ultraInfo;
    }
}
